package com.sangeng.controller;

import com.sangeng.constant.SystemConstants;
import com.sangeng.constant.enums.AppHttpCodeEnum;
import com.sangeng.domain.core.ResponseResult;
import com.sangeng.domain.dto.MenuListDto;
import com.sangeng.domain.entity.Menu;
import com.sangeng.domain.vo.MenuListVo;
import com.sangeng.service.MenuService;
import com.sangeng.utils.BeanUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/system/menu")
public class MenuController {

    @Autowired
    private MenuService menuService;
    @GetMapping("/list")
    public ResponseResult list(MenuListDto menuListDto) {
        return menuService.listAllMenus(menuListDto);
    }

    @PostMapping
    public ResponseResult add(@RequestBody Menu menu) {
        return menuService.addMenu(menu);
    }

    @GetMapping("/{id}")
    public ResponseResult getById(@PathVariable Long id){
        return menuService.getMenuById(id);
    }

    @PutMapping
    public ResponseResult update(@RequestBody Menu menu){
        return menuService.updateMenuById(menu);
    }

    @DeleteMapping("/{id}")
    public ResponseResult delete(@PathVariable Long id){
        return menuService.removeMeunById(id);
    }

    @GetMapping("/treeselect")
    public ResponseResult treeselect() {
        return menuService.treeselect();
    }

    @GetMapping("/roleMenuTreeselect/{id}")
    public ResponseResult roleMenuTreeselect(@PathVariable Long id) {
        return menuService.roleMenuTreeselect(id);
    }
}
